package com.twu.biblioteca;

import java.util.ArrayList;

/**
 * Created by administrator on 14-4-20.
 */
public class userinfor {
    ArrayList<user> users= new ArrayList<user>();
    public userinfor(){
        for (int i = 0; i < 2; i++ ) {
            user user = new user();
            user.setUser_num("0000-00"+i);
            user.setPassword("0000-00"+i);
            user.setName("user"+i);
            user.setEmail(user.getName()+"@163.com");
            user.setPhone("82222222");
            users.add(user);
        }

    }
    public boolean check_user_vaild(String user_num,String password){
        for (int i = 0; i < users.size(); i++){
            if (users.get(i).getUser_num().equals(user_num) && users.get(i).getPassword().equals(password))
                return true;
        }
        return false;
    }
    public user find_userinfor(String usernum){
        user user = new user();
        for (int i = 0 ; i < users.size(); i++){
            if (users.get(i).getUser_num().equals(usernum))
                return users.get(i);
        }
        return user;
    }
    public void show_userinfor(String usernum){
        user user = new user();
        user = find_userinfor(usernum);
        System.out.println(user.getName()+" "+user.getEmail()+" "+user.getPhone());
    }
    public ArrayList<user> getUsers(){
        return users;
    }

}
